import request from "@/util/request";
import type {Page} from "@/api/page/types";
import type {DishesSearchParam, Dishes} from "@/api/dishes/type";

const API: string = '/dishes-service/dishes'

/**
 * 分页查询菜品
 */
export const getDishesList = (form: DishesSearchParam) => {
    return request<Page<Dishes>, Page<Dishes>>({
        url: API+ '/list',
        method: 'get',
        params: form
    })
}

/**
 * 添加菜品
 */
export const addDishes = (form: Dishes) => {
    return request<any, any, Dishes>({
        url: API ,
        method: 'post',
        data: form
    })
}

/**
 * 更新菜品
 */
export const updateDishes = (form: Dishes) => {
    return request<any, any, Dishes>({
        url: `${API}/${form.id}`,
        method: 'put',
        data: form
    })
}

/**
 * 删除菜品
 */
export const deleteDishes = (id: number) => {
    return request<any, any>({
        url: `${API}/${id}`,
        method: 'delete'
    })
}

